const express = require('express');
const router = express.Router();
const bodyParser = require('body-parser'); // 引入 body-parser 中间件

// 使用 body-parser 中间件来解析 POST 请求的请求体
router.use(bodyParser.urlencoded({ extended: false }));
router.use(bodyParser.json());

router.get('/get', (req, res) => {
    const query = req.query;
    res.send({
        status: 0,
        msg: 'GET请求成功',
        data: query
    });
});

router.post('/post', (req, res) => {
    const body = req.body;
    res.send({
        status: 0,
        msg: 'POST请求成功',
        data: body
    });
});

module.exports = router;
